package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.annotation.WebUsed;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.AdoptedRange;
import com.xinhe.web.service.AdoptedRangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@Api(value = "认养数范围", tags = {"认养数范围"})
@RestController
@RequestMapping(value = {"/adoptedRange"}, produces = {"application/json;charset=UTF-8"})

public class AdoptedRangeController {
    @Autowired
    private AdoptedRangeService adoptedRangeService;

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "分页查询认养数范围")
    @RequestMapping({"/pageAdoptedRange"})
    public QueryResults<AdoptedRange> pageAdoptedRange(Integer minNum, Integer maxNum, BigDecimal yunChaSeed, int pageNum, int pageSize) {
        return this.adoptedRangeService.pageAdoptedRange( minNum,  maxNum,  yunChaSeed,  pageNum,  pageSize);
    }
    @WebUsed
    @ApiOperation(httpMethod = "POST", value = "保存认养数范围")
    @RequestMapping({"/saveAdoptedRange"})
    public Result saveAdoptedRange(Integer minNum, Integer maxNum, BigDecimal yunChaSeed, Integer level) {
        return this.adoptedRangeService.saveModel(minNum,maxNum,yunChaSeed,level);
    }


    @ApiOperation(httpMethod = "GET", value = "删除认养数范围")
    @ApiImplicitParam(name = "adoptedRangeId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteAdoptedRange"})
    public Result deleteAdoptedRange(Long adoptedRangeId) {
        return this.adoptedRangeService.delete(adoptedRangeId);
    }

    @ApiOperation(httpMethod = "GET", value = "认养数范围详情")
    @ApiImplicitParam(name = "adoptedRangeId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailAdoptedRange"})
    public Result detailAdoptedRange(Long adoptedRangeId) {
        return this.adoptedRangeService.findById(adoptedRangeId);
    }
}
